<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of WriteOff
 *
 * @author Administrator
 */
class WriteOffList extends WMS_Controller
{
    var $whsCode;
    var $user_data;

    function __construct()
    {
        parent::__construct();
        $gp = gp();
        $this->user_data= $this->session->userdata('users');
        $this->whsCode = $userData['user_main_whs_code'];
        //加载模型
        $this->load->service('wms/part_write_off_service');
        $this->load->service('wms/package_service');
        $this->load->service('wms/api_service');
        $this->load->service('wms/sap_service');
    }
    public function need_list()
    {
        //锁死仓库
        $whs = $this->whsCode;
        $wherein=array('whs_code'=>$whs);
        $where=array(
            'p_status'=>1
        );
        $gp = gp();
        $sku = $gp['sku'] ? $gp['sku'] : '';
        $ref_num = $gp['ref_num'] ? $gp['ref_num'] : '';
        $page = $gp['page'] ? intval($gp['page']) : 1;
        //
        $str='?';
        $page_size=100;
        if(''!=$sku){
        $where['sku']=$sku; 
        $str .= 'sku=' . $sku;
        }
                if(''!=$ref_num){
        $where['ref_num']=$ref_num; 
        $str .= '&ref_num=' . $ref_num;
        }

        //分页查询
        $this->load->library('pagination');
        $config['page_query_string'] = TRUE;
        $config['base_url'] = blang_url('wms/WriteOffList/need_list'.$str);
        $config['total_rows'] = $this->part_write_off_service->get_list_count($where, $wherein, $like);
        $config['uri_segment'] = config_item('enable_lang') ? 5 : 4;
        $config['per_page'] =$page_size;
        $this->pagination->initialize($config);
        $data['pageShow'] = $this->pagination->create_links();
        //分页结束
        //获取产品库存列表
        $receivingList = $this->part_write_off_service->get_list_page(($page - 1) * $page_size, $page_size, $orderstr, $where, $wherein, $like );
        $data['receivingList'] = $this->api_service->fields_erp_product_info($receivingList);
        $this->load->view('defaults/wms/part_write_off_list', $data);
        $this->load->view('defaults/common/footer', $data);
    }
}

?>
